package com.xigua._数学;

import java.util.HashMap;
import java.util.Map;

/**
 * @author LiRongHua
 * @Title: ${file_name}
 * @Package ${package_name}
 * @Description: ${todo}
 * @date 2022/2/915:59
 */
public class _2006_差的绝对值为K的数对数目 {

    public static void main(String[] args) {
        int[] parm = {1,2,2,1};
        System.out.println(countKDifference1(parm, 1));
    }
    public static int countKDifference1(int[] nums, int k) {

        return 0;
    }

    public int countKDifference(int[] nums, int k) {
        int length = nums.length;
        if (length == 1) return 0;
        int ans = 0;
        for (int i = 0; i < length; i++) {
            for (int j = i+1; j < length; j++) {
                int abs = Math.abs(nums[j] - nums[i]);
                if (abs == k || abs == -k) ans++;
            }
        }
        return ans;
    }



}
